home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / os2tools / bnklysrc / b_initva.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-16  |  10.2 KB  |  260 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software <no-Inc>                   */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          No-Cost<no-tm> Software.                       */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello  */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*          This module was originally written by Vince Perriello           */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                   BinkleyTerm Variable Initialization                    */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.210.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU SHOULD  IMMEDIATELY CONTACT THE AUTHORS    */
  27. /*    AT THE  ADDRESSES LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO    */
  28. /*    USE   THIS  FILE  WITHOUT  HAVING   ACCEPTED  THE  TERMS  OF   THE    */
  29. /*    BINKLEYTERM  LICENSING AGREEMENT,  OR SUCH OTHER  AGREEMENT AS YOU    */
  30. /*    ARE ABLE TO REACH WITH THE AUTHORS.                                   */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /*    The Authors can be reached at the following addresses:                */
  34. /*                                                                          */
  35. /*    Robert C. Hartman                      Vincent E. Perriello           */
  36. /*    Spark Software                         VEP Software                   */
  37. /*    427-3 Amherst Street                   111 Carroll Street             */
  38. /*    CS2032, Suite 232                      Naugatuck, CT 06770            */
  39. /*    Nashua, NH 03061                                                      */
  40. /*                                                                          */
  41. /*    FidoNet 1:132/101                      FidoNet 1:141/491              */
  42. /*    Data    (603) 888-8179                 Data    (203) 729-7569         */
  43. /*                                                                          */
  44. /*    Please feel free to contact us at any time to share your comments     */
  45. /*    about our software and/or licensing policies.                         */
  46. /*                                                                          */
  47. /*--------------------------------------------------------------------------*/
  48.  
  49. #include <stdio.h>
  50. #include <time.h>
  51. #include <string.h>
  52. #include <stdlib.h>
  53.  
  54. #ifdef __TURBOC__
  55. #include <mem.h>
  56. #else
  57. #include <memory.h>
  58. #endif
  59.  
  60. #include "com.h"
  61. #include "xfer.h"
  62. #include "zmodem.h"
  63. #include "keybd.h"
  64. #include "sbuf.h"
  65. #include "sched.h"
  66. #include "externs.h"
  67. #include "prototyp.h"
  68.  
  69. static void compile_externs (void);
  70.  
  71. /**
  72.  ** b_initvars -- called before parse_config. Sets defaults that we want
  73.  ** to have set FIRST.
  74.  **/
  75.  
  76.  
  77. void b_initvars ()
  78. {
  79.    int k;
  80.  
  81.    tzset ();
  82.  
  83.    DEFAULT.rq_OKFile = DEFAULT.rq_FILES = DEFAULT.rq_About = DEFAULT.rq_Template = DEFAULT.sc_Inbound = NULL;
  84.    DEFAULT.rq_Limit = 30;                        /* This seems a good default */
  85.  
  86.    KNOWN.rq_OKFile = KNOWN.rq_FILES = KNOWN.rq_About = KNOWN.rq_Template = KNOWN.sc_Inbound = NULL;
  87.    KNOWN.rq_Limit = -1;
  88.  
  89.    PROT.rq_OKFile = PROT.rq_FILES = PROT.rq_About = PROT.rq_Template = PROT.sc_Inbound = NULL;
  90.    PROT.rq_Limit = -1;
  91.  
  92.    for (k = 0; k < 10; k++)                      /* Zero the phone scan list  */
  93.       {
  94.       scan_list[k] = NULL;
  95.       }
  96.  
  97.    for (k = 0; k < MAX_EXTERN; k++)              /* And the external protocols*/
  98.       {
  99.       protocols[k] = NULL;
  100.       }
  101.  
  102.    for (k = 1; k < ALIAS_CNT; k++)               /* And the alias list        */
  103.       {
  104.       alias[k].Zone = alias[k].Net = alias[k].Node = alias[k].Point = 0;
  105.       }
  106.  
  107.    alias[0].Zone = 1;                            /* Make sure we have a zone  */
  108.    alias[0].Net = alias[0].Node = -1;            /* Default Fidonet address   */
  109.    alias[0].Point = 0;
  110.  
  111.    b_init ();
  112.  
  113.    baud = 2;
  114.    cur_baud = atoi (btypes[baud].str);
  115.    command_line_un = 0;
  116. }
  117.  
  118. /**
  119.  ** b_defaultvars -- called after all parse_config passes complete.
  120.  ** sets anything not handled by parse_config to default if we know it.
  121.  **/
  122.  
  123.  
  124. void b_defaultvars ()
  125. {
  126.  
  127.    if (!fullscreen)
  128.       do_screen_blank = 0;
  129.  
  130.    if (modem_init == NULL)
  131.       modem_init = ctl_string ("|AT|");
  132.    if (modem_busy == NULL)
  133.       modem_busy = ctl_string ("|AT|");
  134.  
  135.  
  136.    /* Set up "boss" and "point" addresses correctly if we can */
  137.    
  138.    if (!boss_net)
  139.       {
  140.       boss_net       = alias[0].Net;
  141.       boss_node      = alias[0].Node;
  142.       }
  143.  
  144.    if (alias[0].Point)
  145.       {
  146.       alias[0].Net   = pvtnet;
  147.       alias[0].Node  = alias[0].Point;
  148.       alias[0].Point = 0;
  149.       }
  150.  
  151.    /* If we have the minimum information to do netmail, set the flag */
  152.  
  153.    if ((alias[0].Zone      != 0)
  154.    &&  (alias[0].Net       != 0)
  155.    &&  (system_name        != NULL)
  156.    &&  (sysop              != NULL)
  157.    &&  (hold_area          != NULL)
  158.    &&  (DEFAULT.sc_Inbound != NULL))
  159.       net_params = 1;
  160.  
  161.    /* Make the "higher class" requests at least as well off as the
  162.       "lowest class"... */
  163.  
  164.    if (KNOWN.rq_Limit == -1)
  165.       KNOWN.rq_Limit = DEFAULT.rq_Limit;
  166.    if (KNOWN.rq_FILES == NULL)
  167.       KNOWN.rq_FILES = DEFAULT.rq_FILES;
  168.    if (KNOWN.rq_OKFile == NULL)
  169.       KNOWN.rq_OKFile = DEFAULT.rq_OKFile;
  170.    if (KNOWN.rq_About == NULL)
  171.       KNOWN.rq_About = DEFAULT.rq_About;
  172.    if (KNOWN.rq_Template == NULL)
  173.       KNOWN.rq_Template = DEFAULT.rq_Template;
  174.    if (KNOWN.sc_Inbound == NULL)
  175.       KNOWN.sc_Inbound = DEFAULT.sc_Inbound;
  176.  
  177.    if (PROT.rq_Limit == -1)
  178.       PROT.rq_Limit = KNOWN.rq_Limit;
  179.    if (PROT.rq_FILES == NULL)
  180.       PROT.rq_FILES = KNOWN.rq_FILES;
  181.    if (PROT.rq_OKFile == NULL)
  182.       PROT.rq_OKFile = KNOWN.rq_OKFile;
  183.    if (PROT.rq_About == NULL)
  184.       PROT.rq_About = KNOWN.rq_About;
  185.    if (PROT.rq_Template == NULL)
  186.       PROT.rq_Template = KNOWN.rq_Template;
  187.    if (PROT.sc_Inbound == NULL)
  188.       PROT.sc_Inbound = KNOWN.sc_Inbound;
  189.  
  190.    if (extern_index)
  191.       compile_externs ();                        /* generate extern_protocols */
  192. }
  193.  
  194. static void compile_externs ()
  195. {
  196.    register char *c;
  197.    register i;
  198.    char junk[100];
  199.    int j, k, l;
  200.    char *p;
  201.    char x;
  202.  
  203.    i = l = 0;                                    /* start at beginning  */
  204.    junk [0] = '\0';
  205.  
  206.    for (k = 0; protocols[k] != NULL; k++)        /* Total no. of protos */
  207.       {
  208.       c = protocols[k];                          /* Point at filename   */
  209.       if (!dexists (c))                          /* Is it there?        */
  210.          {
  211.          printf ("Can't find protocol module: %s\n", c);
  212.          continue;
  213.          }
  214.       p = NULL;
  215.       while (*c)                                 /* Until end of string */
  216.          {
  217.          if ((*c == '\\') || (*c == ':'))        /* Look for last path  */
  218.             p = c;                               /* Delimiter           */
  219.          c++;
  220.          }
  221.       if (strlen (p) < 3)                        /* If no name,         */
  222.          continue;                               /* No protocol...      */
  223.  
  224.       p++;                                       /* Point to the        */
  225.       x = toupper (*p);                          /* First character     */
  226.       if (strchr (junk, x) != NULL)
  227.          {
  228.          printf ("Duplicate protocol name: %s\n", c);
  229.          continue;
  230.          }
  231.  
  232.       protos[l].first_char = x;                  /* Makes lookup fast   */
  233.       protos[l++].entry = k;                     /* Now we know where   */
  234.  
  235.       junk[i++] = x;                             /* Store first char    */
  236.       junk[i++] = ')';                           /* Then a ')'          */
  237.       c = ++p;                                   /* Point to 2nd char   */
  238.       for (j = 0; j < 9; j++)                    /* Up to 9 chars more  */
  239.          {
  240.          if (*c != '.')                          /* If no comma yet,    */
  241.             {
  242.             junk[i++] = tolower (*c);            /* store the char and  */
  243.             ++c;                                 /* bump the pointer    */
  244.             }
  245.          else junk[i++] = ' ';                   /* otherwise pad it    */
  246.          }
  247.       junk[i++] = ' ';                           /* And one more space  */
  248.       junk[i] = '\0';                            /* Need for testing    */
  249.       }
  250.  
  251.    if (!i)                                       /* If we got none,     */
  252.       return;                                    /* Return now.         */
  253.  
  254.    i += 2;                                       /* Total for malloc    */
  255.    if ((extern_protocols = malloc (i)) == NULL)  /* Allocate string     */
  256.       return;                                    /* Return on failure   */
  257.    strcpy (extern_protocols, junk);              /* Copy the string     */
  258.    return;                                       /* Back to caller      */
  259. }
  260.